package Chapter9;
import java.awt.*;
import javax.swing.*;
public class Example17  extends JFrame{
	public Example17(){
		this.setTitle("PanelDemo");
		JScrollPane scrollPane=new JScrollPane();
		scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		JPanel panel=new JPanel();
		panel.add(new JButton("1"));
		panel.add(new JButton("2"));
		panel.add(new JButton("3"));
		panel.add(new JButton("4"));
		scrollPane.setViewportView(panel);
		this.add(scrollPane,BorderLayout.CENTER);
		this.setSize(400,250);
		this.setVisible(true);
		
	}
	
	public static void main(String[] args) {
		new Example17();
	}	
}
	